<?php
class Common_Controller_Action_Helper_Acl extends Zend_Controller_Action_Helper_Abstract{
	public $acl;
	
	public function __construct() {
		$this->acl = new Zend_Acl();
	}

	public function setRoles() {
		$this->acl->addRole(new Zend_Acl_Role('guest'));
		$this->acl->addRole(new Zend_Acl_Role('editor'));
		$this->acl->addRole(new Zend_Acl_Role('admin'));

	}

	public function setResources() {
		$defaultModuleResource = new Zend_Acl_Resource('default');	
		$adminsModuleResource = new Zend_Acl_Resource('admins');
		$this->acl->add($defaultModuleResource)
					->add(new Zend_Acl_Resource('default:index'), $defaultModuleResource)
					->add(new Zend_Acl_Resource('default:auth'), $defaultModuleResource)
					->add(new Zend_Acl_Resource('default:numbers'), $defaultModuleResource)
					->add(new Zend_Acl_Resource('default:error'), $defaultModuleResource);
		$this->acl->add($adminsModuleResource)
					->add(new Zend_Acl_Resource('admins:index'), $adminsModuleResource);
		
	}

	public function setPrivilages() {
		$this->acl->allow('guest', 'default');
		$this->acl->deny('guest', 'admins');
		//$this->acl->allow('guest', 'default');
		
	}

	public function setAcl() {
		Zend_Registry::set('acl', $this->acl);
	}

}